//
//  AllColumnTableViewCell.m
//  礼物go
//
//  Created by dllo on 16/5/26.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "AllColumnTableViewCell.h"


@interface AllColumnTableViewCell ()

@property(nonatomic,strong)UIImageView *bgImageView;
@property(nonatomic,strong)UIView *blackView;
@property(nonatomic,strong)UILabel *titleLabel;
@property(nonatomic,strong)UILabel *subTitleLabel;

@property(nonatomic,strong)UIView *lineView;


@end

@implementation AllColumnTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
        self.dk_backgroundColorPicker = DKColorPickerWithRGB(0xFFFAFA,0xBEBEBE);
    }
    return self;
}

-(void)createSubviews{
    self.bgImageView = [UIImageView new];
    //self.bgImageView.backgroundColor = [UIColor purpleColor];
    [self.contentView addSubview:self.bgImageView];
    
    self.blackView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, SCREENWIDTH - 10, 190)];
    CGFloat a = 1.0;
    for (double i = 0; i < 200; i++) {
        a = (i / 200);
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, self.blackView.frame.size.height - i, SCREENWIDTH - 20, 1)];
        view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1.0 - a];
        [self.blackView addSubview:view];
    }
    self.blackView.alpha = 0.5;
    [self.contentView addSubview:self.blackView];

    self.titleLabel = [UILabel new];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.font = [UIFont systemFontOfSize:20];
    self.titleLabel.text = @"主标题";
    [self.contentView addSubview:self.titleLabel];
    
    self.lineView = [[UIView alloc] initWithFrame:CGRectMake(25, self.contentView.frame.size.height / 2, SCREENWIDTH - 50, 3)];
    [self.contentView addSubview:self.lineView];
    
    UIView *leftline = [[UIView alloc] initWithFrame:CGRectMake(0, 1, self.lineView.frame.size.width / 2 - 8, 1)];
    leftline.backgroundColor = [UIColor whiteColor];
    [self.lineView addSubview:leftline];
    
    UIView *rightline = [[UIView alloc] initWithFrame:CGRectMake(self.lineView.frame.size.width / 2 + 8, 1, self.lineView.frame.size.width / 2 - 8, 1)];
    rightline.backgroundColor = [UIColor whiteColor];
    [self.lineView addSubview:rightline];

//    UILabel *smallLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.lineView.frame.size.width / 2 - 6, -3 , 12, 10)];
//    smallLabel.text = @"。";
//    //smallLabel.backgroundColor = [UIColor yellowColor];
//    smallLabel.textColor = [UIColor whiteColor];
//    smallLabel.textAlignment = NSTextAlignmentCenter;
//    [self.lineView addSubview:smallLabel];
    
    self.subTitleLabel = [UILabel new];
    self.subTitleLabel.textAlignment = NSTextAlignmentCenter;
    self.subTitleLabel.textColor = [UIColor whiteColor];
    self.subTitleLabel.text = @"副标题";
    self.subTitleLabel.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:self.subTitleLabel];
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.bgImageView.frame = CGRectMake(10, 10, SCREENWIDTH - 20, self.contentView.frame.size.height - 10);
    self.blackView.frame = CGRectMake(10, self.bgImageView.frame.origin.y, self.bgImageView.frame.size.width, self.bgImageView.frame.size.height);
    
    self.titleLabel.frame = CGRectMake(0, self.contentView.frame.size.height / 2 - 25, self.contentView.frame.size.width, 20);
    self.lineView.frame = CGRectMake(25, self.contentView.frame.size.height / 2, SCREENWIDTH - 50, 3);
    self.subTitleLabel.frame = CGRectMake(0, self.contentView.frame.size.height / 2 + 5, self.contentView.frame.size.width, 20);

}

-(void)setTopicModel:(TopicModel *)topicModel{
    _topicModel = topicModel;
    [self.bgImageView sd_setImageWithURL:[NSURL URLWithString:_topicModel.cover_image_url] placeholderImage:[UIImage imageNamed:@"picholder"]];
    self.titleLabel.text = _topicModel.title;
    self.subTitleLabel.text = _topicModel.subtitle;
    
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
